Chapter 2 Electricity profiles

This chapter provides electricity profiles and a R coding technique. Electricity profiles are illustrated to give an insight into profile behavior. R coding technique are given in order to understand the process flow and manage the big data obtained from several sources in the organization.

2.1 Initial settings

Before the project starts, packages are required as follows:

  • A tidyverse package is a bunch of packages to handle with a data analysis (for more information click here). It consists of data manipulation and visualization as follows:
    • A ggplot2 package is for data visualization.
    • A dplyr package is for data manipulation.
    • A tidyr package is for data tidying.
    • A readr package is for data import.
    • A purrr package is for functional programming.
    • A tibble package is a modern reimagining of the data.frame.
    • A stringr package is for strings.
    • A forcats package is for factors.
    • A lubridate package is for date and time.
  • A readxl package is used for read data from Excel into R.
  • A scales package is applied to scale plots in the ggplot2 package.
  • A glue package interprets strings literal. The package embeds R expressions and inserts into argument string.
  • A knitr package is a lightweight API’s designed to give users full control of the output without heavy coding work. In this project, the package is used for making a HTML.
library(tidyverse) #For data manipulation
library(readxl) #For reading the excel sheet
library(scales)
library(glue)
library(knitr)
library(plotly)

Theme and lines for figures are set in a variable named Themeline as follows:

  • theme_bw() function provides a black and white theme.
  • theme() function applied for setting theme and line represented in plots.
  • linepalette1 and linepalette1 variables set line colors.
ThemeLine <- 
  theme_bw() +
  theme(
    panel.border=element_rect(fill=NA),
    panel.grid.minor = element_line(color = NA), 
    #    axis.title=element_text(size=5),
    #    axis.text.x = element_text(hjust=1,size = 10, angle = 0),
    axis.line=element_line(colour="black"),
    panel.background=element_rect(fill = "white"),
    panel.grid.major.x=element_line(linetype="dashed",colour="grey",linewidth = 0.5),
    panel.grid.major.y = element_blank(),
    # panel.grid.major=element_blank(),
    strip.background=element_rect(fill="white", colour="white"),
    strip.text.x = element_text(size=10, colour = "black", angle = 0,face="bold"),
    axis.text.x=element_text(size = 10,angle=45, vjust=0.9, hjust=1, margin = unit(c(t = 0.3, r = 0, b = 0, l = 0), "cm")),
    axis.text.y=element_text(size = 10,margin = unit(c(t = 0, r = 0.3, b = 0, l = 0), "cm")),
    legend.text = element_text(size = 10),
    legend.title = element_text(size = 10),
    axis.ticks.length=unit(-0.15,"cm")
  )
linepalette1 <- c("#4DAF4A","#FF7F00","#377EB8","#E41A1C","#984EA3","#F781BF","#8DD3C7","#FB8072","#80B1D3","#FDB462","#B3DE69","#FCCDE5","#D9D9D9","#BC80BD","#CCEBC5","#FFED6F","#7f878f","#A65628","#FFFF33")
linepalette2 <- c("#E41A1C","#FF7F00","#377EB8","#B3DE69","#4DAF4A","#984EA3","#F781BF","#8DD3C7","#FB8072","#80B1D3","#FDB462","#FCCDE5","#D9D9D9","#BC80BD","#CCEBC5","#FFED6F","#7f878f","#A65628","#FFFF33")

Lists are create to store variables.

#----- Make a list of profile to store data -----####

profiledata <- list()
profilefigure <- list()
summarydata <- list()
#----- Make variable for output directory -----####
outfigdir <- c("figures/")

2.2 The EGAT electrity sale profiles

2.2.1 The 2019 Metropolitan Electricity Authority (MEA) EGAT sale profile

The electricity sale profile from EGAT is given by the Power System Control and Operation Division (ฝ่ายควบคุมระบบกำลังไฟฟ้า).

#----- The 2019 MEA EGAT sale profile ----####
# Profile data ####
profile <- 
  read_excel("raw_data/raw_data_profiles/02_Hourly Sale_NetGen_2019.xlsx",
           sheet = "Load Curve",
           range = "C3:D17523"
            ) %>% 
  select(datetime = `Date/Time`, MEA) %>% 
  mutate(date = date(datetime),
         time = format(as.POSIXct(datetime),"%H:%M:%S"),
         year = year(datetime),
         month = month(datetime),
         day = day(datetime)) %>% 
  select(datetime, date, time, year, month, day, MEA)
Table 2.1: The 2019 EGAT sale to MEA profile
datetime date time year month day MEA
2019-01-01 00:00:00 2019-01-01 00:00:00 2019 1 1 3361.083
2019-01-01 00:30:00 2019-01-01 00:30:00 2019 1 1 3244.405
2019-01-01 01:00:00 2019-01-01 01:00:00 2019 1 1 3199.672
2019-01-01 01:30:00 2019-01-01 01:30:00 2019 1 1 3153.101
2019-01-01 02:00:00 2019-01-01 02:00:00 2019 1 1 3085.642

The peak, minimun in the unit of MW, and an electricity sale to MEA in GWh from the profile are calculated. The electricity sale to MEA (in GWh) is calculated by the summation of profile in MW divided by 2000.

The reason to divide by 2,000 is that the profile is given a time stamp in every 30-min. There are 17,520 values. Therefore, the profile is divided by 2 to get the results in every 1 hr.. We divided the output by 1,000 to convert the unit from MWh to GWh (see equation (2.1)).

\[\begin{equation} Ene_{t}=\frac{\sum_{i=1}^{17520} (profile_{t,i})}{2*1000} \tag{2.1} \end{equation}\]

Where, \(Ene_{t}\) denotes an calculated energy (electricity) in year \(t\).
\(profile_{t,i}\) denotes a generation in the unit of MW in year \(t\) at a time stamp \(i\).
\(i\) denotes a time stamp in a 30-minute interval. Therefore, there are 17,520 intervals in a year (8,760 hrs.).

# Summary data ####
maxv <- ceiling(max(profile$MEA)) # Get a peak MW
minv <- floor(min(profile$MEA)) # Get a min MW
energy <- sum(profile$MEA)/2000 # Calculate the energy

The peak and minimum MW days are also needed to assess in order to provide the maximum and minimum a saled electricity from EGAT to MEA.

peak_day <- profile %>% #Find a peak day
            group_by(year) %>% 
            filter(MEA == max(MEA)) %>% 
            pull(datetime)
min_day <- profile %>% #Find a peak day
           group_by(year) %>% 
           filter(MEA == min(MEA)) %>% 
           pull(datetime)

Load factor is calculated by the energy in equation (2.1) divided a maximum energy. A maximum energy is the peak multiplied by 8760 hours. Result is presented in a percentage.

\[\begin{equation} LF_{t}=\frac{Energy_{t}}{Peak_{d,h} * 8760}*100 \tag{2.2} \end{equation}\]

Where, \(LF_{t}\) denotes the load factor at year \(t\) in percentage.
\(Energy_{t}\) denotes the calculated energy from equation (2.1) at year \(t\) in GWh.
\(Peak_{d,h}\) denotes the peak electricity sale on the date \(d\) at time \(h\).

load_factor <- percent((energy*10^3)/(maxv*8760), 
                       accuracy = 0.01, 
                       decimal.mark = ".")

Create a table to store relevant data.

summary <- tibble(peak_day = peak_day,
                  min_day = min_day,
                  peak_mw = maxv, 
                  min_mw = minv, 
                  energy_gwh = energy,
                  load_factor = load_factor) # combine all data in 1 table

In 2019, the electricity sale to MEA by EGAT reached it peak 9,526 MW on 2019-04-25 14:00:00. The energy (electricity) sale to MEA was 54,939.73 GWh. The summary of the electricity sale to MEA by EGAT in 2019 is given in Table 2.2.

Table 2.2: Summary of EGAT sale to MEA in 2019
peak_day min_day peak_mw min_mw energy_gwh load_factor
2019-04-25 14:00:00 2019-01-01 05:00:00 9526 2748 54939.73 65.84%

The 2019 electricity sale profile from EGAT to MEA is illustrated (see Figure 2.1).

profile_plot <-
    ggplot() + 
    geom_line(data=profile, 
              aes(x = datetime, 
                  y = MEA,
                  group = month,
                  color = as.factor(month)),
              show.legend = FALSE) +
    ThemeLine +
    labs(x = NULL,
         y = "EGAT sale to MEA (MW)")+
    scale_x_datetime(breaks=date_breaks("1 month"), 
                     labels=date_format("%b %y")) +
    scale_y_continuous(breaks = seq(0, round(maxv,-3),1000),
                       limits = c(0, round(maxv, -3))) +  
    scale_color_manual(values = linepalette1) +
    geom_point(data=summary,
               aes(x = peak_day, y = peak_mw))+
    geom_text(data = summary,
              aes(x = peak_day, y = round(maxv, -3)),
              label = glue("Peak {maxv} MW \n@ {peak_day}"))+
    geom_point(data=summary,
               aes(x = min_day, y = min_mw))+
    geom_text(data = summary,
              aes(x = min_day, y = round(minv, -3)),
              label = glue("Minimum {minv} MW \n@ {min_day}"),
              hjust = 0,
              vjust = 1.5)

Figure 2.1: EGAT electricity sale profile to MEA in 2019.

Outputs are saved. Outputs are listed as follows:

  • Create a file name mea_egtsle_2019.png
  • Save a plot in a directory using ggsave() function
  • Save profile data in a profiledata list
  • Save figures in a profilefigure list
  • Save summary data in a summarydata list
outputfigure <- paste0(outfigdir, "mea_egtsle_2019.png")
ggsave(profile_plot, file = outputfigure, dpi = 150, width = 15, height = 5, units = "in", limitsize = FALSE)
profiledata <- c(profiledata, list("mea_egtsle_2019" = profile))
profilefigure <- c(profilefigure, list("mea_egtsle_2019" = profile_plot))
summarydata <- c(summarydata, list("sum_mea_egtsle_2019" = summary))

2.2.2 The 2019 Provincial Electricity Authority (PEA) EGAT sale profiles

2.2.2.1 The 2019 PEA-R1 (Central region) EGAT sale profile

Read a profile data

profile <- 
  read_excel("raw_data/raw_data_profiles/02_Hourly Sale_NetGen_2019.xlsx",
             sheet = "Load Curve",
             range = "C3:E17523"
  ) %>% 
  select(datetime = `Date/Time`, PEA_R1) %>% 
  mutate(date = date(datetime),
         time = format(as.POSIXct(datetime),"%H:%M:%S"),
         year = year(datetime),
         month = month(datetime),
         day = day(datetime)) %>% 
  select(datetime, date, time, year, month, day, PEA_R1)
Table 2.3: The 2019 EGAT sale to PEA R1 profile
datetime date time year month day PEA_R1
2019-01-01 00:00:00 2019-01-01 00:00:00 2019 1 1 5036.982
2019-01-01 00:30:00 2019-01-01 00:30:00 2019 1 1 4907.355
2019-01-01 01:00:00 2019-01-01 01:00:00 2019 1 1 4929.126
2019-01-01 01:30:00 2019-01-01 01:30:00 2019 1 1 4793.341
2019-01-01 02:00:00 2019-01-01 02:00:00 2019 1 1 4789.811
maxv <- ceiling(max(profile$PEA_R1)) # Get a peak MW
minv <- floor(min(profile$PEA_R1)) # Get a min MW
energy <- sum(profile$PEA_R1)/2000 # Calculate the energy
peak_day <- profile %>% #Find a peak day
  group_by(year) %>% 
  filter(PEA_R1 == max(PEA_R1)) %>% 
  pull(datetime)
min_day <- profile %>% #Find a peak day
  group_by(year) %>% 
  filter(PEA_R1 == min(PEA_R1)) %>% 
  pull(datetime)
load_factor <- percent((energy*10^3)/(maxv*8760), 
                       accuracy = 0.01, 
                       decimal.mark = ".")
summary <- tibble(peak_day = peak_day,
                  min_day = min_day,
                  peak_mw = maxv, 
                  min_mw = minv, 
                  energy_gwh = energy,
                  load_factor = load_factor) 
Table 2.4: Summary of EGAT sale to PEA R1 in 2019
peak_day min_day peak_mw min_mw energy_gwh load_factor
2019-05-03 23:00:00 2019-01-01 12:00:00 11936 3293 80961.36 77.43%

The 2019 electricity sale profile from EGAT to PEA-R1 is illustrated (see Figure 2.2).

profile_plot <-
  ggplot() + 
  geom_line(data=profile, 
            aes(x = datetime, 
                y = PEA_R1,
                group = month,
                color = as.factor(month)),
            show.legend = FALSE) +
  ThemeLine +
  labs(x = NULL,
       y = "EGAT sale to PEA R1 (Central region) (MW)")+
  scale_x_datetime(breaks=date_breaks("1 month"), 
                   labels=date_format("%b %y")) +
  scale_y_continuous(breaks = seq(0, round(maxv,-3),1000),
                     limits = c(0, round(maxv, -3))) +  
  scale_color_manual(values = linepalette1) +
  geom_point(data=summary,
             aes(x = peak_day, y = peak_mw))+
  geom_text(data = summary,
            aes(x = peak_day, y = round(maxv, -3)),
            label = glue("Peak {maxv} MW \n@ {peak_day}"))+
  geom_point(data=summary,
             aes(x = min_day, y = min_mw))+
  geom_text(data = summary,
            aes(x = min_day, y = round(minv, -3)),
            label = glue("Minimum {minv} MW \n@ {min_day}"),
            hjust = 0,
            vjust = 1.5)

Figure 2.2: EGAT electricity sale profile to PEA-R1 in 2019.

outputfigure <- paste0(outfigdir, "pea_r1_central_egtsle_2019.png")
ggsave(profile_plot, file = outputfigure, dpi = 150, width = 15, height = 5, units = "in", limitsize = FALSE)
profiledata <- c(profiledata, list("pea_r1_central_egtsle_2019" = profile))
profilefigure <- c(profilefigure, list("pea_r1_central_egtsle_2019" = profile_plot))
summarydata <- c(summarydata, list("sum_pea_r1_central_egtsle_2019" = summary))

2.2.2.2 The 2019 PEA-R2 (North Eastern region) EGAT sale profile

# Profile data ####
profile <- 
  read_excel("raw_data/raw_data_profiles/02_Hourly Sale_NetGen_2019.xlsx",
             sheet = "Load Curve",
             range = "C3:F17523"
  ) %>% 
  select(datetime = `Date/Time`, PEA_R2) %>% 
  mutate(date = date(datetime),
         time = format(as.POSIXct(datetime),"%H:%M:%S"),
         year = year(datetime),
         month = month(datetime),
         day = day(datetime)) %>% 
  select(datetime, date, time, year, month, day, PEA_R2) #%>% 
# mutate(strdatetime = as.factor(strptime(glue("{year}-{month}-{day} {time}"), "%Y-%m-%d %H:%M:%S")))
Table 2.5: The 2019 EGAT sale to PEA R2 profile
datetime date time year month day PEA_R2
2019-01-01 00:00:00 2019-01-01 00:00:00 2019 1 1 1459.520
2019-01-01 00:30:00 2019-01-01 00:30:00 2019 1 1 1415.846
2019-01-01 01:00:00 2019-01-01 01:00:00 2019 1 1 1350.192
2019-01-01 01:30:00 2019-01-01 01:30:00 2019 1 1 1287.925
2019-01-01 02:00:00 2019-01-01 02:00:00 2019 1 1 1231.863
# Summary data ####
maxv <- ceiling(max(profile$PEA_R2)) # Get a peak MW
minv <- floor(min(profile$PEA_R2)) # Get a min MW
energy <- sum(profile$PEA_R2)/2000 # Calculate the energy
peak_day <- profile %>% #Find a peak day
  group_by(year) %>% 
  filter(PEA_R2 == max(PEA_R2)) %>% 
  pull(datetime)
min_day <- profile %>% #Find a peak day
  group_by(year) %>% 
  filter(PEA_R2 == min(PEA_R2)) %>% 
  pull(datetime)
load_factor <- percent((energy*10^3)/(maxv*8760), 
                       accuracy = 0.01, 
                       decimal.mark = ".")
summary <- tibble(peak_day = peak_day,
                  min_day = min_day,
                  peak_mw = maxv, 
                  min_mw = minv, 
                  energy_gwh = energy,
                  load_factor = load_factor) # combine all data in 1 table
Table 2.6: Summary of EGAT sale to PEA R2 in 2019
peak_day min_day peak_mw min_mw energy_gwh load_factor
2019-04-20 21:00:00 2019-01-01 12:00:00 3803 970 20007.86 60.06%
# Plot a profile ####

profile_plot <-
  ggplot() + 
  geom_line(data=profile, 
            aes(x = datetime, 
                y = PEA_R2,
                group = month,
                color = as.factor(month)),
            show.legend = FALSE) +
  ThemeLine +
  labs(x = NULL,
       y = "EGAT sale to PEA R2 (North Eastern region) (MW)")+
  scale_x_datetime(breaks=date_breaks("1 month"), 
                   labels=date_format("%b %y")) +
  scale_y_continuous(breaks = seq(0, round(maxv,-3),1000),
                     limits = c(0, round(maxv, -3))) +  
  scale_color_manual(values = linepalette1) +
  geom_point(data=summary,
             aes(x = peak_day, y = peak_mw))+
  geom_text(data = summary,
            aes(x = peak_day, y = round(maxv, -3)),
            label = glue("Peak {maxv} MW \n@ {peak_day}"))+
  geom_point(data=summary,
             aes(x = min_day, y = min_mw))+
  geom_text(data = summary,
            aes(x = min_day, y = round(minv, -3)),
            label = glue("Minimum {minv} MW \n@ {min_day}"),
            hjust = 0,
            vjust = 1.5)

# Save the output ####
outputfigure <- paste0(outfigdir, "pea_r2_northeastern_egtsle_2019.png")
ggsave(profile_plot, file = outputfigure, dpi = 150, width = 15, height = 5, units = "in", limitsize = FALSE)
profiledata <- c(profiledata, list("pea_r2_northeastern_egtsle_2019" = profile))
profilefigure <- c(profilefigure, list("pea_r2_northeastern_egtsle_2019" = profile_plot))
summarydata <- c(summarydata, list("sum_pea_r2_northeastern_egtsle_2019" = summary))

The 2019 electricity sale profile from EGAT to PEA-R2 is illustrated in Figure 2.3).

Figure 2.3: EGAT electricity sale profile to PEA-R2 in 2019.

2.2.2.3 The 2019 PEA-R3 (Southern region) EGAT sale profile

# Profile data ####
profile <- 
  read_excel("raw_data/raw_data_profiles/02_Hourly Sale_NetGen_2019.xlsx",
             sheet = "Load Curve",
             range = "C3:G17523"
  ) %>% 
  select(datetime = `Date/Time`, PEA_R3) %>% 
  mutate(date = date(datetime),
         time = format(as.POSIXct(datetime),"%H:%M:%S"),
         year = year(datetime),
         month = month(datetime),
         day = day(datetime)) %>% 
  select(datetime, date, time, year, month, day, PEA_R3) #%>% 
# mutate(strdatetime = as.factor(strptime(glue("{year}-{month}-{day} {time}"), "%Y-%m-%d %H:%M:%S")))
Table 2.7: The 2019 EGAT sale to PEA R3 profile
datetime date time year month day PEA_R3
2019-01-01 00:00:00 2019-01-01 00:00:00 2019 1 1 1641.250
2019-01-01 00:30:00 2019-01-01 00:30:00 2019 1 1 1601.345
2019-01-01 01:00:00 2019-01-01 01:00:00 2019 1 1 1593.385
2019-01-01 01:30:00 2019-01-01 01:30:00 2019 1 1 1569.930
2019-01-01 02:00:00 2019-01-01 02:00:00 2019 1 1 1535.770
# Summary data ####
maxv <- ceiling(max(profile$PEA_R3)) # Get a peak MW
minv <- floor(min(profile$PEA_R3)) # Get a min MW
energy <- sum(profile$PEA_R3)/2000 # Calculate the energy
peak_day <- profile %>% #Find a peak day
  group_by(year) %>% 
  filter(PEA_R3 == max(PEA_R3)) %>% 
  pull(datetime)
min_day <- profile %>% #Find a peak day
  group_by(year) %>% 
  filter(PEA_R3 == min(PEA_R3)) %>% 
  pull(datetime)
load_factor <- percent((energy*10^3)/(maxv*8760), 
                       accuracy = 0.01, 
                       decimal.mark = ".")
summary <- tibble(peak_day = peak_day,
                  min_day = min_day,
                  peak_mw = maxv, 
                  min_mw = minv, 
                  energy_gwh = energy,
                  load_factor = load_factor) # combine all data in 1 table
Table 2.8: Summary of EGAT sale to PEA R3 in 2019
peak_day min_day peak_mw min_mw energy_gwh load_factor
2019-04-25 19:30:00 2019-01-05 04:00:00 2609 1293 17009.67 74.42%
# Plot a profile ####

profile_plot <-
  ggplot() + 
  geom_line(data=profile, 
            aes(x = datetime, 
                y = PEA_R3,
                group = month,
                color = as.factor(month)),
            show.legend = FALSE) +
  ThemeLine +
  labs(x = NULL,
       y = "EGAT sale to PEA R3 (Southern region) (MW)")+
  scale_x_datetime(breaks=date_breaks("1 month"), 
                   labels=date_format("%b %y")) +
  scale_y_continuous(breaks = seq(0, round(maxv,-3),1000),
                     limits = c(0, round(maxv, -3))) +  
  scale_color_manual(values = linepalette1) +
  geom_point(data=summary,
             aes(x = peak_day, y = peak_mw))+
  geom_text(data = summary,
            aes(x = peak_day, y = round(maxv, -3)),
            label = glue("Peak {maxv} MW \n@ {peak_day}"))+
  geom_point(data=summary,
             aes(x = min_day, y = min_mw))+
  geom_text(data = summary,
            aes(x = min_day, y = round(minv, -3)),
            label = glue("Minimum {minv} MW \n@ {min_day}"),
            hjust = 0,
            vjust = 1.5)

# Save the output ####
outputfigure <- paste0(outfigdir, "pea_r3_southern_egtsle_2019.png")
ggsave(profile_plot, file = outputfigure, dpi = 150, width = 15, height = 5, units = "in", limitsize = FALSE)
profiledata <- c(profiledata, list("pea_r3_southern_egtsle_2019" = profile))
profilefigure <- c(profilefigure, list("pea_r3_southern_egtsle_2019" = profile_plot))
summarydata <- c(summarydata, list("sum_pea_r3_southern_egtsle_2019" = summary))

The 2019 electricity sale profile from EGAT to PEA-R3 is illustrated in Figure 2.4).

Figure 2.4: EGAT electricity sale profile to PEA-R3 in 2019.

2.2.2.4 The 2019 PEA-R4 (Northern region) EGAT sale profile

# Profile data ####
profile <- 
  read_excel("raw_data/raw_data_profiles/02_Hourly Sale_NetGen_2019.xlsx",
             sheet = "Load Curve",
             range = "C3:H17523"
  ) %>% 
  select(datetime = `Date/Time`, PEA_R4) %>% 
  mutate(date = date(datetime),
         time = format(as.POSIXct(datetime),"%H:%M:%S"),
         year = year(datetime),
         month = month(datetime),
         day = day(datetime)) %>% 
  select(datetime, date, time, year, month, day, PEA_R4) #%>% 
Table 2.9: The 2019 EGAT sale to PEA R4 profile
datetime date time year month day PEA_R4
2019-01-01 00:00:00 2019-01-01 00:00:00 2019 1 1 1287.513
2019-01-01 00:30:00 2019-01-01 00:30:00 2019 1 1 1231.703
2019-01-01 01:00:00 2019-01-01 01:00:00 2019 1 1 1195.394
2019-01-01 01:30:00 2019-01-01 01:30:00 2019 1 1 1139.654
2019-01-01 02:00:00 2019-01-01 02:00:00 2019 1 1 1082.499
Table 2.10: Summary of EGAT sale to PEA R4 in 2019
peak_day min_day peak_mw min_mw energy_gwh load_factor
2019-05-20 21:30:00 2019-12-09 03:30:00 3224 941 16572.57 58.68%
# Plot a profile ####

profile_plot <-
  ggplot() + 
  geom_line(data=profile, 
            aes(x = datetime, 
                y = PEA_R4,
                group = month,
                color = as.factor(month)),
            show.legend = FALSE) +
  ThemeLine +
  labs(x = NULL,
       y = "EGAT sale to PEA R4 (Northern region) (MW)")+
  scale_x_datetime(breaks=date_breaks("1 month"), 
                   labels=date_format("%b %y")) +
  scale_y_continuous(breaks = seq(0, round(maxv,-3)*1.2,1000),
                     limits = c(0, round(maxv, -3)*1.2)) +  
  scale_color_manual(values = linepalette1) +
  geom_point(data=summary,
             aes(x = peak_day, y = peak_mw))+
  geom_text(data = summary,
            aes(x = peak_day, y = round(maxv, -3)*1.2),
            label = glue("Peak {maxv} MW \n@ {peak_day}"))+
  geom_point(data=summary,
             aes(x = min_day, y = min_mw))+
  geom_text(data = summary,
            aes(x = min_day, y = round(minv, -3)),
            label = glue("Minimum {minv} MW \n@ {min_day}"),
            hjust = 0.5,
            vjust = 1.5)

# Save the output ####
outputfigure <- paste0(outfigdir, "pea_r4_northern_egtsle_2019.png")
ggsave(profile_plot, file = outputfigure, dpi = 150, width = 15, height = 5, units = "in", limitsize = FALSE)
profiledata <- c(profiledata, list("pea_r4_northern_egtsle_2019" = profile))
profilefigure <- c(profilefigure, list("pea_r4_northern_egtsle_2019" = profile_plot))
summarydata <- c(summarydata, list("sum_pea_r4_northern_egtsle_2019" = summary))

The 2019 electricity sale profile from EGAT to PEA-R4 is illustrated in Figure 2.5).

Figure 2.5: EGAT electricity sale profile to PEA-R4 in 2019.

2.2.2.5 The 2019 PEA (All regions) EGAT sale profile

# Profile data ####
profile <- 
  read_excel("raw_data/raw_data_profiles/02_Hourly Sale_NetGen_2019.xlsx",
             sheet = "Load Curve",
             range = "C3:I17523"
  ) %>% 
  select(datetime = `Date/Time`, PEA) %>% 
  mutate(date = date(datetime),
         time = format(as.POSIXct(datetime),"%H:%M:%S"),
         year = year(datetime),
         month = month(datetime),
         day = day(datetime)) %>% 
  select(datetime, date, time, year, month, day, PEA) 
Table 2.11: The 2019 EGAT sale to PEA (all regions) profile
datetime date time year month day PEA
2019-01-01 00:00:00 2019-01-01 00:00:00 2019 1 1 9425.265
2019-01-01 00:30:00 2019-01-01 00:30:00 2019 1 1 9156.250
2019-01-01 01:00:00 2019-01-01 01:00:00 2019 1 1 9068.097
2019-01-01 01:30:00 2019-01-01 01:30:00 2019 1 1 8790.850
2019-01-01 02:00:00 2019-01-01 02:00:00 2019 1 1 8639.943
Table 2.12: Summary of EGAT sale to PEA (all regions) in 2019
peak_day min_day peak_mw min_mw energy_gwh load_factor
2019-04-20 21:00:00 2019-01-01 12:00:00 21151 6877 134551.5 72.62%
# Plot a profile ####

profile_plot <-
  ggplot() + 
  geom_line(data=profile, 
            aes(x = datetime, 
                y = PEA,
                group = month,
                color = as.factor(month)),
            show.legend = FALSE) +
  ThemeLine +
  labs(x = NULL,
       y = "EGAT sale to PEA (All regions) (MW)")+
  scale_x_datetime(breaks=date_breaks("1 month"), 
                   labels=date_format("%b %y")) +
  scale_y_continuous(breaks = seq(0, round(maxv,-3)*1.1,1000),
                     limits = c(0, round(maxv, -3)*1.1)) +  
  scale_color_manual(values = linepalette1) +
  geom_point(data=summary,
             aes(x = peak_day, y = peak_mw))+
  geom_text(data = summary,
            aes(x = peak_day, y = round(maxv, -3)*1.1),
            label = glue("Peak {maxv} MW \n@ {peak_day}"))+
  geom_point(data=summary,
             aes(x = min_day, y = min_mw))+
  geom_text(data = summary,
            aes(x = min_day, y = round(minv, -3)),
            label = glue("Minimum {minv} MW \n@ {min_day}"),
            hjust = -0.1,
            vjust = 1.5)

# Save the output ####
outputfigure <- paste0(outfigdir, "pea_allregion_egtsle_2019.png")
ggsave(profile_plot, file = outputfigure, dpi = 150, width = 15, height = 5, units = "in", limitsize = FALSE)
profiledata <- c(profiledata, list("pea_allregion_egtsle_2019" = profile))
profilefigure <- c(profilefigure, list("pea_allregion_egtsle_2019" = profile_plot))
summarydata <- c(summarydata, list("sum_pea_allregion_egtsle_2019" = summary))

The 2019 electricity sale profile from EGAT to PEA (all regions) is illustrated in Figure 2.6).

Figure 2.6: EGAT electricity sale profile to PEA (all regions) in 2019.

2.2.3 The 2019 Direct Customer (DC) EGAT sale profiles

2.2.3.1 The 2019 DC in in PEA R1 (Central region) EGAT sale profiles

# Profile data ####
profile <- 
  read_excel("raw_data/raw_data_profiles/02_Hourly Sale_NetGen_2019.xlsx",
             sheet = "Load Curve",
             range = "C3:J17523"
  ) %>% 
  select(datetime = `Date/Time`, DCs_R1) %>% 
  mutate(date = date(datetime),
         time = format(as.POSIXct(datetime),"%H:%M:%S"),
         year = year(datetime),
         month = month(datetime),
         day = day(datetime)) %>% 
  select(datetime, date, time, year, month, day, DCs_R1) #%>% 
Table 2.13: The 2019 EGAT sale to direct customer in PEA-R1 profile
datetime date time year month day DCs_R1
2019-01-01 00:00:00 2019-01-01 00:00:00 2019 1 1 201.253
2019-01-01 00:30:00 2019-01-01 00:30:00 2019 1 1 202.469
2019-01-01 01:00:00 2019-01-01 01:00:00 2019 1 1 190.028
2019-01-01 01:30:00 2019-01-01 01:30:00 2019 1 1 196.300
2019-01-01 02:00:00 2019-01-01 02:00:00 2019 1 1 177.956
Table 2.14: Summary of EGAT sale to direct customer in PEA-R1 in 2019
peak_day min_day peak_mw min_mw energy_gwh load_factor
2019-03-23 05:30:00 2019-09-11 13:00:00 421 81 2006.585 54.41%
# Plot a profile ####

profile_plot <-
  ggplot() + 
  geom_line(data=profile, 
            aes(x = datetime, 
                y = DCs_R1,
                group = month,
                color = as.factor(month)),
            show.legend = FALSE) +
  ThemeLine +
  labs(x = NULL,
       y = "EGAT sale to direct customers in PEA R1 (Central region) (MW)")+
  scale_x_datetime(breaks=date_breaks("1 month"), 
                   labels=date_format("%b %y")) +
  scale_y_continuous(breaks = seq(0, round(maxv,-2)*1.2,100),
                     limits = c(0, round(maxv, -2)*1.2)) +  
  scale_color_manual(values = linepalette1) +
  geom_point(data=summary,
             aes(x = peak_day, y = peak_mw))+
  geom_text(data = summary,
            aes(x = peak_day, y = round(maxv, -2)*1.2),
            label = glue("Peak {maxv} MW \n@ {peak_day}"))+
  geom_point(data=summary,
             aes(x = min_day, y = min_mw))+
  geom_text(data = summary,
            aes(x = min_day, y = round(minv, -2)),
            label = glue("Minimum {minv} MW \n@ {min_day}"),
            hjust = 0,
            vjust = 1.5)

# Save the output ####
outputfigure <- paste0(outfigdir, "dc_r1_central_egtsle_2019.png")
ggsave(profile_plot, file = outputfigure, dpi = 150, width = 15, height = 5, units = "in", limitsize = FALSE)
profiledata <- c(profiledata, list("dc_r1_central_egtsle_2019" = profile))
profilefigure <- c(profilefigure, list("dc_r1_central_egtsle_2019" = profile_plot))
summarydata <- c(summarydata, list("sum_dc_r1_central_egtsle_2019" = summary))

The 2019 electricity sale profile from EGAT to direct customer in PEA-R1 is illustrated in Figure 2.7).

Figure 2.7: EGAT electricity sale profile to direct customer in PEA-R1 in 2019.

2.2.3.2 The 2019 DC in in PEA R2 (North Eastern region) EGAT sale profiles

# Profile data ####
profile <- 
  read_excel("raw_data/raw_data_profiles/02_Hourly Sale_NetGen_2019.xlsx",
             sheet = "Load Curve",
             range = "C3:K17523"
  ) %>% 
  select(datetime = `Date/Time`, DCs_R2) %>% 
  mutate(date = date(datetime),
         time = format(as.POSIXct(datetime),"%H:%M:%S"),
         year = year(datetime),
         month = month(datetime),
         day = day(datetime)) %>% 
  select(datetime, date, time, year, month, day, DCs_R2) #%>% 
Table 2.15: The 2019 EGAT sale to direct customer in PEA-R2 profile
datetime date time year month day DCs_R2
2019-01-01 00:00:00 2019-01-01 00:00:00 2019 1 1 45.91
2019-01-01 00:30:00 2019-01-01 00:30:00 2019 1 1 74.97
2019-01-01 01:00:00 2019-01-01 01:00:00 2019 1 1 72.34
2019-01-01 01:30:00 2019-01-01 01:30:00 2019 1 1 70.17
2019-01-01 02:00:00 2019-01-01 02:00:00 2019 1 1 68.94
Table 2.16: Summary of EGAT sale to direct customer in PEA-R2 in 2019
peak_day min_day peak_mw min_mw energy_gwh load_factor
2019-05-20 22:30:00 2019-09-17 07:30:00 609 0 1300.891 24.38%
# Plot a profile ####

profile_plot <-
  ggplot() + 
  geom_line(data=profile, 
            aes(x = datetime, 
                y = DCs_R2,
                group = month,
                color = as.factor(month)),
            show.legend = FALSE) +
  ThemeLine +
  labs(x = NULL,
       y = "EGAT sale to direct customers in PEA R2 (North Eastern region) (MW)")+
  scale_x_datetime(breaks=date_breaks("1 month"), 
                   labels=date_format("%b %y")) +
  scale_y_continuous(breaks = seq(0, round(maxv,-2)*1.2,100),
                     limits = c(0, round(maxv, -2)*1.2)) +  
  scale_color_manual(values = linepalette1) +
  geom_point(data=summary,
             aes(x = peak_day, y = peak_mw))+
  geom_text(data = summary,
            aes(x = peak_day, y = round(maxv, -2)*1.1),
            label = glue("Peak {maxv} MW \n@ {peak_day}"))+
  geom_point(data=summary,
             aes(x = min_day, y = min_mw))+
  geom_text(data = summary,
            aes(x = min_day, y = round(minv, -2)),
            label = glue("Minimum {minv} MW \n@ {min_day}"),
            hjust = 0,
            vjust = 0)

# Save the output ####
outputfigure <- paste0(outfigdir, "dc_r2_northeastern_egtsle_2019.png")
ggsave(profile_plot, file = outputfigure, dpi = 150, width = 15, height = 5, units = "in", limitsize = FALSE)
profiledata <- c(profiledata, list("dc_r2_northeastern_egtsle_2019" = profile))
profilefigure <- c(profilefigure, list("dc_r2_northeastern_egtsle_2019" = profile_plot))
summarydata <- c(summarydata, list("sum_dc_r2_northeastern_egtsle_2019" = summary))

The 2019 electricity sale profile from EGAT to direct customer in PEA-R2 is illustrated in Figure 2.8).

Figure 2.8: EGAT electricity sale profile to direct customer in PEA-R2 in 2019.

2.2.3.3 The 2019 DC in in PEA R3 (Southern region) EGAT sale profiles

# Profile data ####
profile <- 
  read_excel("raw_data/raw_data_profiles/02_Hourly Sale_NetGen_2019.xlsx",
             sheet = "Load Curve",
             range = "C3:L17523"
  ) %>% 
  select(datetime = `Date/Time`, DCs_R3) %>% 
  mutate(date = date(datetime),
         time = format(as.POSIXct(datetime),"%H:%M:%S"),
         year = year(datetime),
         month = month(datetime),
         day = day(datetime)) %>% 
  select(datetime, date, time, year, month, day, DCs_R3) #%>% 
Table 2.17: The 2019 EGAT sale to direct customer in PEA-R3 profile
datetime date time year month day DCs_R3
2019-01-01 00:00:00 2019-01-01 00:00:00 2019 1 1 17.170
2019-01-01 00:30:00 2019-01-01 00:30:00 2019 1 1 16.990
2019-01-01 01:00:00 2019-01-01 01:00:00 2019 1 1 16.455
2019-01-01 01:30:00 2019-01-01 01:30:00 2019 1 1 17.045
2019-01-01 02:00:00 2019-01-01 02:00:00 2019 1 1 16.760
Table 2.18: Summary of EGAT sale to direct customer in PEA-R3 in 2019
peak_day min_day peak_mw min_mw energy_gwh load_factor
2019-12-14 15:00:00 2019-03-30 14:30:00 253 0 419.8491 18.94%
# Plot a profile ####

profile_plot <-
  ggplot() + 
  geom_line(data=profile, 
            aes(x = datetime, 
                y = DCs_R3,
                group = month,
                color = as.factor(month)),
            show.legend = FALSE) +
  ThemeLine +
  labs(x = NULL,
       y = "EGAT sale to direct customers in PEA R3 (Southern region) (MW)")+
  scale_x_datetime(breaks=date_breaks("1 month"), 
                   labels=date_format("%b %y")) +
  scale_y_continuous(breaks = seq(0, round(maxv,-2),100),
                     limits = c(0, round(maxv, -2))) +  
  scale_color_manual(values = linepalette1) +
  geom_point(data=summary,
             aes(x = peak_day, y = peak_mw))+
  geom_text(data = summary,
            aes(x = peak_day, y = round(maxv, -2)),
            label = glue("Peak {maxv} MW \n@ {peak_day}"))+
  geom_point(data=summary,
             aes(x = min_day, y = min_mw))+
  geom_text(data = summary,
            aes(x = min_day, y = round(minv, -2)),
            label = glue("Minimum {minv} MW \n@ {min_day}"),
            hjust = 0,
            vjust = 0)

# Save the output ####
outputfigure <- paste0(outfigdir, "dc_r3_southern_egtsle_2019.png")
ggsave(profile_plot, file = outputfigure, dpi = 150, width = 15, height = 5, units = "in", limitsize = FALSE)
profiledata <- c(profiledata, list("dc_r3_southern_egtsle_2019" = profile))
profilefigure <- c(profilefigure, list("dc_r3_southern_egtsle_2019" = profile_plot))
summarydata <- c(summarydata, list("sum_dc_r3_southern_egtsle_2019" = summary))

The 2019 electricity sale profile from EGAT to direct customer in PEA-R3 is illustrated in Figure 2.9).

Figure 2.9: EGAT electricity sale profile to direct customer in PEA-R3 in 2019.

2.2.3.4 The 2019 DC in in PEA R4 (Northern region) EGAT sale profiles

# Profile data ####
profile <- 
  read_excel("raw_data/raw_data_profiles/02_Hourly Sale_NetGen_2019.xlsx",
             sheet = "Load Curve",
             range = "C3:M17523"
  ) %>% 
  select(datetime = `Date/Time`, DCs_R4) %>% 
  mutate(date = date(datetime),
         time = format(as.POSIXct(datetime),"%H:%M:%S"),
         year = year(datetime),
         month = month(datetime),
         day = day(datetime)) %>% 
  select(datetime, date, time, year, month, day, DCs_R4) #%>% 
Table 2.19: The 2019 EGAT sale to direct customer in PEA-R4 profile
datetime date time year month day DCs_R4
2019-01-01 00:00:00 2019-01-01 00:00:00 2019 1 1 18.341
2019-01-01 00:30:00 2019-01-01 00:30:00 2019 1 1 20.824
2019-01-01 01:00:00 2019-01-01 01:00:00 2019 1 1 20.921
2019-01-01 01:30:00 2019-01-01 01:30:00 2019 1 1 28.174
2019-01-01 02:00:00 2019-01-01 02:00:00 2019 1 1 24.071
Table 2.20: Summary of EGAT sale to direct customer in PEA-R4 in 2019
peak_day min_day peak_mw min_mw energy_gwh load_factor
2019-02-02 16:00:00 2019-12-31 10:30:00 67 0 250.4462 42.67%
# Plot a profile ####

profile_plot <-
  ggplot() + 
  geom_line(data=profile, 
            aes(x = datetime, 
                y = DCs_R4,
                group = month,
                color = as.factor(month)),
            show.legend = FALSE) +
  ThemeLine +
  labs(x = NULL,
       y = "EGAT sale to direct customers in PEA R4 (Northern region) (MW)")+
  scale_x_datetime(breaks=date_breaks("1 month"), 
                   labels=date_format("%b %y")) +
  scale_y_continuous(breaks = seq(0, round(maxv,-1),10),
                     limits = c(0, round(maxv, -1))) +  
  scale_color_manual(values = linepalette1) +
  geom_point(data=summary,
             aes(x = peak_day, y = peak_mw))+
  geom_text(data = summary,
            aes(x = peak_day, y = round(maxv, -1)),
            label = glue("Peak {maxv} MW \n@ {peak_day}"),
            hjust = 0.5) +
  geom_point(data=summary,
             aes(x = min_day, y = min_mw))+
  geom_text(data = summary,
            aes(x = min_day, y = round(minv, -1)),
            label = glue("Minimum {minv} MW \n@ {min_day}"),
            hjust = 1,
            vjust = -0.5)

# Save the output ####
outputfigure <- paste0(outfigdir, "dc_r4_northern_egtsle_2019.png")
ggsave(profile_plot, file = outputfigure, dpi = 150, width = 15, height = 5, units = "in", limitsize = FALSE)
profiledata <- c(profiledata, list("dc_r4_northern_egtsle_2019" = profile))
profilefigure <- c(profilefigure, list("dc_r4_northern_egtsle_2019" = profile_plot))
summarydata <- c(summarydata, list("dc_r4_northern_egtsle_2019" = summary))

The 2019 electricity sale profile from EGAT to direct customer in PEA-R4 is illustrated in Figure 2.10).

Figure 2.10: EGAT electricity sale profile to direct customer in PEA-R4 in 2019.

2.2.3.5 The 2019 DC in in PEA (All regions) EGAT sale profiles

# Profile data ####
profile <- 
  read_excel("raw_data/raw_data_profiles/02_Hourly Sale_NetGen_2019.xlsx",
             sheet = "Load Curve",
             range = "C3:N17523"
  ) %>% 
  select(datetime = `Date/Time`, DCs) %>% 
  mutate(date = date(datetime),
         time = format(as.POSIXct(datetime),"%H:%M:%S"),
         year = year(datetime),
         month = month(datetime),
         day = day(datetime)) %>% 
  select(datetime, date, time, year, month, day, DCs) #%>% 
Table 2.21: The 2019 EGAT sale to direct customer in PEA (all regions) profile
datetime date time year month day DCs
2019-01-01 00:00:00 2019-01-01 00:00:00 2019 1 1 282.674
2019-01-01 00:30:00 2019-01-01 00:30:00 2019 1 1 315.253
2019-01-01 01:00:00 2019-01-01 01:00:00 2019 1 1 299.744
2019-01-01 01:30:00 2019-01-01 01:30:00 2019 1 1 311.689
2019-01-01 02:00:00 2019-01-01 02:00:00 2019 1 1 287.727
Table 2.22: Summary of EGAT sale to direct customer in PEA (all regions) in 2019
peak_day min_day peak_mw min_mw energy_gwh load_factor
2019-12-14 10:00:00 2019-07-10 16:30:00 1043 111 3977.771 43.54%
# Plot a profile ####

profile_plot <-
  ggplot() + 
  geom_line(data=profile, 
            aes(x = datetime, 
                y = DCs,
                group = month,
                color = as.factor(month)),
            show.legend = FALSE) +
  ThemeLine +
  labs(x = NULL,
       y = "EGAT sale to direct customers in PEA (All regions) (MW)")+
  scale_x_datetime(breaks=date_breaks("1 month"), 
                   labels=date_format("%b %y")) +
  scale_y_continuous(breaks = seq(0, round(maxv,-2)*1.2,100),
                     limits = c(0, round(maxv, -2)*1.2)) +  
  scale_color_manual(values = linepalette1) +
  geom_point(data=summary,
             aes(x = peak_day, y = peak_mw))+
  geom_text(data = summary,
            aes(x = peak_day, y = round(maxv, -2)*1.2),
            label = glue("Peak {maxv} MW \n@ {peak_day}"),
            hjust = 0.5,
            vjust = 1.5) +
  geom_point(data=summary,
             aes(x = min_day, y = min_mw))+
  geom_text(data = summary,
            aes(x = min_day, y = round(minv, -2)),
            label = glue("Minimum {minv} MW \n@ {min_day}"),
            # hjust = 0,
            vjust = 1)

# Save the output ####
outputfigure <- paste0(outfigdir, "dc_allregions_egtsle_2019.png")
ggsave(profile_plot, file = outputfigure, dpi = 150, width = 15, height = 5, units = "in", limitsize = FALSE)
profiledata <- c(profiledata, list("dc_allregions_egtsle_2019" = profile))
profilefigure <- c(profilefigure, list("dc_allregions_egtsle_2019" = profile_plot))
summarydata <- c(summarydata, list("sum_dc_allregions_egtsle_2019" = summary))

The 2019 electricity sale profile from EGAT to direct customer in PEA (all regions) is illustrated in Figure 2.11).

Figure 2.11: EGAT electricity sale profile to direct customer in PEA (all regions) in 2019.

2.2.4 The 2019 PEA R1 & DC R1 (Central region)EGAT electrity sale profiles

The electricity profile

\[\begin{equation} $Prf_{r,t,h}=\ Prf_{PEA,t,h} + Prf_{DC,t,h}$ \tag{2.3} \end{equation}\]

Where, \(Prf_{r,t,h}\) denotes an calculated profile in region \(r\), year \(t\), and time \(h\) (MW).
\(Prf_{PEA,t,h}\) denotes a profile in PEA from each region in year \(t\) at time \(h\) (MW).
\(Prf_{DC,t,h}\) denotes a profile from direct customer in each PEA region in year \(t\) at time \(h\) (MW).

# Profile data ####
profile <- 
  
  profiledata$pea_r1_central_egtsle_2019%>%
  mutate(dc_r1 = profiledata$dc_r1_central_egtsle_2019$DCs_R1,
         r1_egt_sle = PEA_R1 + dc_r1) %>% 
  select(-PEA_R1, -dc_r1)